//
//  ShowQrCodeVc.m
//  Project_Demo
//
//  Created by caoxiaozhu on 2018/7/23.
//  Copyright © 2018年 caoxiaozhu. All rights reserved.
//

#import "ShowQrCodeVc.h"

@interface ShowQrCodeVc ()<showQrDelegate>
@property(nonatomic,strong)UIImage *codeImage;
@property(nonatomic,strong)ShowQrView *qrView;

@end

@implementation ShowQrCodeVc

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}


-(void)setupUI{

    NSLog(@"cardStr==>%@",self.cardStr);

    _qrView = [[[NSBundle mainBundle]loadNibNamed:@"ShowQrView" owner:self options:nil]firstObject];
    _qrView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    _qrView.delegate = self;
    
//    __weak typeof(self)weakSelf = self;
    kWeakSelf(self);
    [HMScannerController cardImageWithCardName:self.cardStr avatar:nil scale:0.2 completion:^(UIImage *image) {
        weakself.qrView.qrImageView.image = image;
    }];
    
    [self.view addSubview:_qrView];
}

-(void)refreshQrcode{
    NSLog(@"手动刷新");
    self.cardStr = [NSString stringWithFormat:@"%d",arc4random_uniform(32)];
    [_qrView removeFromSuperview];
    [self setupUI];
}


@end
